﻿using UnityEngine;
using System.Collections;

public class Pistol : Gun {

    public LineRenderer lineRender;

    public override void Fire()
    {
        if (target)
        {

            lineRender.SetPosition(0, firePoint.position);
            lineRender.enabled = true;

            RaycastHit hitinfo;

            if (Physics.Raycast(transform.position, firePoint.forward, out hitinfo, range, whatIsEnemy))
            {
                lineRender.SetPosition(0, hitinfo.point);
                hitinfo.transform.GetComponent<Character>().TakeDamage(attack, hitinfo.point);
                lineRender.enabled = false;
                canFire = false;
                Ammo--;
            }
        }
        else
        {
            lineRender.enabled = false;
            lineRender.SetPosition(0, firePoint.position);
        }
    }

}